# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Tuan Hoang <tmhoang@linux.ibm.com>
pkgname=s390-tools
pkgver=2.12.0
pkgrel=1
pkgdesc="Tools for use with the s390 Linux kernel and device drivers"
url="https://github.com/ibm-s390-tools/s390-tools"
arch="s390x"
license="MIT"
depends="bash"
makedepends="$depends_dev linux-headers libexecinfo-dev zlib-dev fuse-dev ncurses-dev openssl-dev cryptsetup-dev json-c-dev"
triggers="$pkgname.trigger=/boot"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/ibm-s390-tools/s390-tools/archive/v$pkgver.tar.gz
	0002-musl-fixes.patch
	0004-missing-time-header.patch
	0006-define-path-mounted.patch
	0007-tunedasd-no-need-error-h.patch
	0008-iucvterm-no-nls.patch
	0009-link-libexecinfo.patch
	0010-musl-s390x-signal-def.patch

	0101-zipl-dont-optimize-size.patch

	0200-dasdinfo-gnu-ext-hack.patch
	0300-disable-program-using-gnu-ext.patch
	bash.patch
	argz.patch

	argz.c
	argz.h
	Makefile.argz
	mk-s390-cdboot.c
	"

build() {
	mkdir -p "$builddir"/libargz
	cp "$srcdir"/argz.h "$builddir"/include/argz.h
	cp "$srcdir"/argz.c "$builddir"/libargz/argz.c
	cp "$srcdir"/Makefile.argz "$builddir"/libargz/Makefile
	make -j1 V=1 CFLAGS="$CFLAGS -D_GNU_SOURCE" \
		HAVE_SNMP=0 \
		HAVE_PFM=0 \
		DISTRELEASE="Alpine" \
		LIBEXECINFO_LIBS="-lexecinfo"
	gcc -Wall -o mk-s390-cdboot "$srcdir"/mk-s390-cdboot.c
}

package() {
	make HAVE_SNMP=0 HAVE_PFM=0 DESTDIR="$pkgdir" DISTRELEASE="Alpine" install
	install -Dm755 mk-s390-cdboot "$pkgdir"/sbin/mk-s390-cdboot
}

sha512sums="4903ded5368966513e1090faca04482316870cf5fc53206d17ab98b821541e2836a016bd18cd1ca49ed6b5df0dff92dd1ed257ff712920a7aa3fd74e4a6bc6a0  s390-tools-2.12.0.tar.gz
32ef9d80a1385df3dca9c749cd0fc15c112ab662b736cef271ed70cbdaa7c8b66c41995b42f350377860a5de754bf8721cb27dc095c2e1293cfe7f5e434ef182  0002-musl-fixes.patch
6e0f8d999eef08677e9f80d1a07e01556474723b9b00435d463428eee22babe4489257ad5c8fffb650bd0fd5714cdac01dc926e1402f9741fc1327d177ece897  0004-missing-time-header.patch
e41548d83d53e4371afcee3601505520506d05b932aeb91f1ca86e589c010fa5d22777d4617c1e25adfc04fbcf45289cf65a8100108c878323e125e312579220  0006-define-path-mounted.patch
ecfbba213d2a705e2a5a2697090f659670ca1a12e4568c1de87f17d11d72a1a6c524b23b4db25c0558b4e8239c27afddb94d8887d93170b359d77985018f9b9c  0007-tunedasd-no-need-error-h.patch
bdbeb6f3873ede82487c7e4fcac84aa2bf8a922991ec32d029a64cd7142625f5a99920db0f1b6935805d7371ae5a7640c5ea577969937dd96c4f4f996b909ac3  0008-iucvterm-no-nls.patch
798ae2128a2e419a2e76f3198ac7563e84470069571beffd673b9cfc1755f432afaa32d730fd1c43db890009f37bc11a7a00af6e7e6b41ea7ffd789469eaef25  0009-link-libexecinfo.patch
f785a899583de8592422e5e46c4e4893196e3c7885e4a0bb4c717c3587db8c1a4c264c80337b1d0c31b39150f3c3b71b876fe156086ace3a542c12678ae7c85e  0010-musl-s390x-signal-def.patch
f8565253e87e717ea943101b3d270109260099481764ba7905a72c2c5817885a7071ce656ff59a697d075dd4c0b2eb8d02f6aeeb2cb98e47ac1f27d08b109137  0101-zipl-dont-optimize-size.patch
f5e06e28f77c44f591d74f383ce308a6bfb129b00b291601f2be8866dd1382c597348794be2109c9dc0fa8fdbbee509d036fa6c215e73c4c99f476d3c1cb5a83  0200-dasdinfo-gnu-ext-hack.patch
78ec9fa561f039ea44c2efb9ce7ad396746f1c2889165836342a0584266fc514599aff9f8ace7ac420d62de3543d09d2082bcdccaebb616ba4928b847d7466ab  0300-disable-program-using-gnu-ext.patch
0c4b8da70b6e64ff2da56cda6e89c95654b4c9c75376e9a5165c1083c832e85386f70990539c6ab101ed64fe30bf94ae4709aabf967fdd773b0b6b19b8c4aee8  bash.patch
96e204ffde62e6c9e43a9d7d5e4120054fa9ae8cd8a94e7ea02569228115d2e8c903faf9db093bf9a2341089e0384c4155fcf0fd8d6e8030bff3f5c28ca9884c  argz.patch
2e573314d4c4ed90b61da28de22ae8e2f68ced5489f7e5e0b30f51b776efaf40c1f781d3b485418572d8f33a169fa6946b7358cbd4a7de5a3724b20ed622262b  argz.c
50bd5c0f555963dadbfaa72df5bf0801a48743d6d0feddb6ebfa4ffa410196216c1860d3a577361e035169fea4217aef3f04d69394c59db65b60c5ea29eba8cb  argz.h
5e19ccfce59a2a79863db676b0ea4280cb9016cda1a30dc233526f52425c305410dd148453b75c2613acac37e364305ee25f8e545d57c5059cca19a13bac2a5e  Makefile.argz
349eb06895016d16194819c4a04f604720f1373ea61a9bc4c58467281c9a2ed3539bd4e8b6984f4e5177630dbe8b928aa95912c9a3e3b0e1fe275d59f9fe573d  mk-s390-cdboot.c"
